package com.zjdiepu.www.manage.api.base;
import java.util.List;
import java.util.Map;

import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.zjdiepu.www.base.BaseController;
import com.zjdiepu.www.base.enums.type.AttachmentLabel;
import com.zjdiepu.www.base.enums.type.AttachmentSort;
import com.zjdiepu.www.base.enums.type.AttachmentType;
import com.zjdiepu.www.base.enums.type.ModeIDType;
import com.zjdiepu.www.common.util.CollectionInitUtil;
import com.zjdiepu.www.model.base.dto.SysUser;
import com.zjdiepu.www.model.base.response.Nemu;
import com.zjdiepu.www.util.CachedEnums;

/**
* 所属公司：稻普控股集团
* 项目名称：dpqc-parent-manager-home   
* 类名称：SysUserController   
* 类描述：   
* 创建人：zhangpp
* 创建时间：2017年4月7日 下午12:01:58   
* 修改人：zhangpp
* 修改时间：2017年4月7日 下午12:01:58   
* 修改备注：   
* @version V1.0
 */
@Controller
@RequestMapping(value = "user", produces="text/html;charset=UTF-8", method = RequestMethod.GET)
public class SysUserPageController extends BaseController {
	@RequestMapping(value = "homepage")
	public String homePage(Model model){
		SysUser currentUser =(SysUser)getCurrentUser();
		Map<String, List<Nemu>> map = CollectionInitUtil.emptyMap();
		Map<String, List<Nemu>> userNemus = currentUser.getNemus();
		String powerCode = null;
		if(null != userNemus) {
			List<Nemu> top = userNemus.get("top");
			map.put("top", top);
			if(CollectionUtils.isNotEmpty(top)) {
				Nemu nemu = top.get(0);
				powerCode = nemu.getPowerCode();
			}
		}
		if("ywpt:base".equals(powerCode)) {
			return "index";
		} else if("bbptfalse:base".equals(powerCode)){
			return "indexfalsereform";
		} else if("glzhx:base".equals(powerCode)){
			return "indexmanage";
		} else if("bbpt:base".equals(powerCode)){
			return "indexreform";
		} else {
			return "index";
		}
		
	}
	@RequestMapping(value = "login")
	public String loginPage(Model model) {
		return "login/login";
	}
	@RequestMapping(value = "toAdd")
	public String toAdd(Model model)
	{
		//判断条件
		model.addAttribute("modeIDTypeNames", CachedEnums.getNames(ModeIDType.class));
		model.addAttribute("attachmentTypeNames", CachedEnums.getNames(AttachmentType.class));
		model.addAttribute("attachmentSortNames", CachedEnums.getNames(AttachmentSort.class));
		model.addAttribute("attachmentLabelNames", CachedEnums.getNames(AttachmentLabel.class));
		model.addAttribute("attachmentLabelNameValues", CachedEnums.getNameValues(AttachmentLabel.class));
		return "system/powerManage/userAdd";
	}
	@RequestMapping(value = "toUpdate")
	public String toUpdate(Model model)
	{
		//判断条件
		model.addAttribute("modeIDTypeNames", CachedEnums.getNames(ModeIDType.class));
		model.addAttribute("attachmentTypeNames", CachedEnums.getNames(AttachmentType.class));
		model.addAttribute("attachmentSortNames", CachedEnums.getNames(AttachmentSort.class));
		model.addAttribute("attachmentLabelNames", CachedEnums.getNames(AttachmentLabel.class));
		model.addAttribute("attachmentLabelNameValues", CachedEnums.getNameValues(AttachmentLabel.class));
		return "system/powerManage/userUpdate";
	}
}
